package net.homelinux.chaoswg.io.renga.krypto.animations.Subtract;

import net.homelinux.chaoswg.io.renga.core.animations.State;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.Unsigned8Bit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.UnsignedNBit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.UnsignedNBitFactory;

public class SubtractState implements State {
    UnsignedNBit minuend = new Unsigned8Bit();
    UnsignedNBit subtrahend = new Unsigned8Bit();
    UnsignedNBit result = new Unsigned8Bit();
    
    public SubtractState (UnsignedNBit minuend, UnsignedNBit subtrahend) {
        this.minuend= minuend;
        this.subtrahend = subtrahend;
        
        result = UnsignedNBitFactory.createUnsignedNBitFactory().get(minuend.getN());
    }
    
    public SubtractState (){ }

    
    public UnsignedNBit getMinuend() {
        return minuend;
    }
    public void setMinuend(UnsignedNBit minuend) {
        this.minuend = minuend;
    }
    public UnsignedNBit getResult() {
        return result;
    }
    public void setResult(UnsignedNBit result) {
        this.result = result;
    }
    public UnsignedNBit getSubtrahend() {
        return subtrahend;
    }
    public void setSubtrahend(UnsignedNBit subtrahend) {
        this.subtrahend = subtrahend;
    }
    
    public void setOperand(final int slot, final Object value) {
        if (value instanceof UnsignedNBit) {
            switch (slot) {
                case 0:
                    minuend = ((UnsignedNBit)value);
                    result = UnsignedNBitFactory.createUnsignedNBitFactory().get(minuend.getN());
                    break;
                case 1:
                    subtrahend = ((UnsignedNBit)value);
                    result = UnsignedNBitFactory.createUnsignedNBitFactory().get(subtrahend.getN());
                    break;
            }
        }
    }

}
